package com.zz.webapp.common;

/**
 * Created by zhouzeng on 2017/1/9.
 */
public class PageInfo {

    public static final String LIMIT = "limit";
    public static final String OFFSET = "offset";
    private Integer offset;
    private Integer limit;


    public PageInfo() {}

    public static PageInfo of(Integer pageNo, Integer size) {
        return new PageInfo(pageNo, size);
    }

    public PageInfo(Integer pageNo, Integer size) {
        pageNo =  pageNo == null ? Integer.valueOf(1) : pageNo;
        size = size == null ? Integer.valueOf(10) : size;
        this.limit = Integer.valueOf(size.intValue() > 0?size.intValue():10);
        this.offset = Integer.valueOf((pageNo.intValue() - 1) * size.intValue());
        this.offset = Integer.valueOf(this.offset.intValue() > 0?this.offset.intValue():0);
    }

    public Integer getOffset() {
        return this.offset;
    }

    public void setOffset(Integer offset) {
        this.offset = offset;
    }

    public Integer getLimit() {
        return this.limit;
    }

    public void setLimit(Integer limit) {
        this.limit = limit;
    }

}
